<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <include file="Public:header" />

</head>
<body>
  <include file="Public:body_top" />

  <div class="container-fluid">
    <div class="row">
      <div class="col-sm-3 col-md-2 sidebar hidden-xs">
        <div class="menu">
          <dl>
            <dt><i class="cm-order"></i>商品管理</dt>
            <dd><a href="{:U('Products/index')}">商品列表</a></dd>
          </dl>
          <dl>
            <dt><i class="cm-order"></i>商品库管理</dt>
            <dd class="active"><a href="{:U('Products/plat_index')}">商品库</a></dd>
            <dd><a href="{:U('Products/plat_cate_index')}">商品库分类</a></dd>
            <dd><a href="{:U('Products/plat_new_cate')}">新建商品分类</a></dd>
            <dd><a href="{:U('Products/plat_new_product')}">新建商品</a></dd>
          </dl>
        </div>
      </div>
      <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
        <div class="main-hd">
          <h5>商品库</h5>
        </div>
        <div class="main-bd">
          <form method="post" action="{:U('Products/plat_index')}" class="form-horizontal form-box clearfix">
            <div class="col-md-3">
              <div class="form-group">
                <label class="col-sm-4 control-label">商品名</label>
                <div class="col-sm-8">
                  <input class="form-control" name="name" type="text" placeholder="输入商品名" value="{$name}">
                </div>
              </div>
            </div>
            <div class="col-md-3">
              <button type="submit" class="btn btn-primary">查询</button>
            </div>
          </form>

          <div class="table-responsive">
            <table class="table table-cmcm">
              <tr>
                <th>ID</th>
                <th>Logo</th>
                <th>名称</th>
                <th>价格</th>
                <th>代理价</th>
                <th>库存</th>
                <th>入库限时</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
              </tr>

              <volist name="page_list.list" id="vo">
                <tr>
                  <td>{$vo.id}</td>
                  <td>
                    <notempty name="vo.logo">
                      <a class="cm-detail" title="查看logo" href="{$vo.logo}" target="_blank">
                <img src="{$vo.logo}" style="width:40px; height:40px;"></a></notempty>
                  </td>
                  <td>{$vo.name}</td>
                  <td>{$vo.price}</td>
                  <td>{$vo.proxy_price}</td>
                  <td>{$vo.product_num}</td>
                  <td>{$vo.limit_depot}</td>
                  <td class="index_status">
                    <if condition="$vo.status eq 0 ">
                      <a href='{:U("Products/change_status", "id=$vo[id]&status=1")}'>下架</a>
                      <elseif condition="$vo.status eq 1 " /> <a href='{:U("Products/change_status", "id=$vo[id]&status=0")}'>上架</a>
                    </if>
                  </td>
                  <td>{$vo.created_at}</td>
                  <td>
                    <a data-toggle="modal" onClick="show_spec('{$vo.spec}', '{$vo.sales}', '{$vo.hits}')" data-target="#common-modal" title="查看规格" href="#">详情</a> |
                    <a href='{:U("Products/plat_edit_product", "id=$vo[id]")}'>编辑</a> |
                    <if condition="$vo.status eq 2 ">
                      <a href='{:U("Products/change_status", "id=$vo[id]&status=1")}'>恢复</a>
                      <else /> <a href='{:U("Products/change_status", "id=$vo[id]&status=2")}'>删除</a>
                    </if>
                  </td>
                </tr>
              </volist>
            </table>
          </div>

          <ul class="pagination pull-right">
            <li>
              <a href="{$page_list.page.first.href}" aria-label="Previous">
                <span aria-hidden="true">&laquo;</span>
              </a>
            </li>
            <li>
              <a href="{$page_list.page.front.href}" aria-label="Previous">
                <span aria-hidden="true">&lt;</span>
              </a>
            </li>
            <volist name="page_list.page.list" id="plist">
              <li <eq name="plist.index" value="1">class="active"</eq>><a href="{$plist.href}">{$plist.page}</a></li>
            </volist>

            <li>
              <a href="{$page_list.page.after.href}" aria-label="Next">
                <span aria-hidden="true">&gt;</span>
              </a>
            </li>
            <li>
              <a href="{$page_list.page.last.href}" aria-label="Next">
                <span aria-hidden="true">&raquo;</span>
              </a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>

  <div class="modal fade" id="common-modal">
    <div class="modal-dialog">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title">商品详情</h4>
        </div>
        <div class="modal-body">
          <div class="table-responsive">
            <table class="table table-cmcm">
              <tr>
                <th>规格</th>
                <th>价格</th>
              </tr>
              <tbody class="product-item-hd">

              </tbody>
            </table>
            <table class="table table-cmcm">
              <tr>
                <th>销量</th>
                <th>浏览</th>
              </tr>
              <tr>
                <td class="product-sales"></td>
                <td class="product-hits"></td>
              </tr>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/javascript">
    function show_spec(spec, sales, hits) {
      $('.product-item-hd').html(spec);
      $('.product-sales').html(sales);
      $('.product-hits').html(hits);
    }
  </script>
</body>

</html>